Better return nil than an arbitrary xml:lang="..." value
...for a localized property that doesn't have a suitable value, but is nillable.
E.g., /org.openoffice.Office.Writer/Insert/Caption/CaptionOrderNumberingFirst
(once fixed to indeed be a localized property as apparently intended, with a
follow-up commit to this) only has an explicit value (true) for xml:lang="hu",
but shouldn't return that for any other locale (where the implicit default for a
nil value should instead be false, cf. the else branch at the end of
SwInsertConfig::Load, sw/source/uibase/config/modcfg.cxx).
Change-Id: I7b991c1bc4df22bf2359175b0734e85e0844ce99
Reviewed-on: https://gerrit.libreoffice.org/49409
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
diff --git a/configmgr/source/access.cxx b/configmgr/source/access.cxx
index 0d19af3..718f6339 100644
--- a/configmgr/source/access.cxx
+++ b/configmgr/source/access.cxx
@@ -1430,9 +1430,8 @@
}
}
}
// Defaults are the "en-US" locale, the "en" locale, the empty string
// locale, the first child (if any), or a null ChildAccess, in that
// order:
// Defaults are the "en-US" locale, the "en" locale, the empty string locale, the first child (if
// any, and if the property is non-nillable), or a null ChildAccess, in that order:
rtl::Reference< ChildAccess > child(getChild("en-US"));
if (child.is()) {
return child;
@@ -1445,9 +1444,11 @@
if (child.is()) {
return child;
}
std::vector< rtl::Reference< ChildAccess > > children(getAllChildren());
if (!children.empty()) {
return children.front();
if (!static_cast<LocalizedPropertyNode *>(getNode().get())->isNillable()) {
std::vector< rtl::Reference< ChildAccess > > children(getAllChildren());
if (!children.empty()) {
return children.front();
}
}
return rtl::Reference< ChildAccess >();
}